use url::Url;
use std::sync::Arc;
use youtube_dl::{Error, SingleVideo, YoutubeDl, YoutubeDlOutput};
pub async fn youtube(url: Arc<Url>) -> Result<Option<SingleVideo>, Error> {
    let output = YoutubeDl::new(url.to_string())
        .socket_timeout("10")
        .youtube_dl_path("yt-dlp")
        .run_async()
        .await?;
    match output {
        YoutubeDlOutput::SingleVideo(video) => Ok(Some(*video)),
        _ => Ok(None),
    }
}
